package cn.jilian.meta.handler.generators;

import java.util.Map;
import cn.jilian.entity.Meta;
import cn.jilian.meta.handler.CompGenerator;
import cn.jilian.meta.handler.GeneratorManager;
import cn.jilian.meta.handler.domain.TreeModel;
import cn.jilian.meta.handler.domain.TreeStore;

public class SimpleTreeStoreGenerator implements CompGenerator<TreeStore> {

	private GeneratorManager manager;
	
	private CompGenerator<TreeModel> treeModelGenerator;
	
	public SimpleTreeStoreGenerator(GeneratorManager manager) {
		this.manager=manager;
		this.treeModelGenerator=this.manager.getGenerator(TreeModel.class);
	}

	@Override
	public TreeStore convert(Meta meta, Map<String, Object> extConfig) {
		TreeStore store=new TreeStore();
		TreeModel model=treeModelGenerator.convert(meta, extConfig);
		store.setNodeParam("id");
		store.setModel(model);
		return store;
	}

}
